USE SAS
GO

IF EXISTS (SELECT 1 from sysobjects where xtype = 'FN' AND NAME = 'GetVerticalsXml')
	DROP FUNCTION dbo.GetVerticalsXml
GO


CREATE FUNCTION dbo.GetVerticalsXml ()
RETURNS VARCHAR(MAX)
AS
BEGIN
	
	declare 
		@xml			varchar(max)

	SET @xml		= '<VERTICALS><entry id="0"></entry>'

	SELECT @xml = @xml + '<entry id="' + CAST(Vertical AS VARCHAR) + '"><![CDATA['+VerticalDesc +']]></entry>' 
	from TR_VERTICAL order by VerticalDesc
	set @xml = @xml + '</VERTICALS>'

	return @xml
END


-- SELECT dbo.GetVerticalsXml()